<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ai_app', function (Blueprint $table) {
            $table->comment('客户端管理');
            $table->increments('id');
            $table->string('app_key')->index()->default('')->comment('应用Key');
            $table->string('app_secret')->default('')->comment('应用秘钥');
            $table->dateTime('expire_at')->index()->comment('有效期');
            $table->integer('total_num')->default(new \Illuminate\Database\Query\Expression('0'))->comment('剩余次数');
            $table->string('description')->nullable()->comment('备注');
            $table->bigInteger('token')->default(new \Illuminate\Database\Query\Expression('0'))->comment('剩余token');
            $table->bigInteger('used_token')->default(new \Illuminate\Database\Query\Expression('0'))->comment('已用token');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ai_app');
    }
};
